﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace debioscoopincdrie.Managers
{
    class PlanningManager
    {
        #region Fields
        private static PlanningManager INSTANCE;
        #endregion

        #region Constructors
        private PlanningManager()
        {
        }
        #endregion

        #region Static functions
        public static PlanningManager GetManager()
        {
            if (INSTANCE == null)
            {
                INSTANCE = new PlanningManager();
            }

            return INSTANCE;
        }
        #endregion

        #region Functions
        public planning GetPlanning(int movieID, DateTime date, TimeSpan movieTime)
        {
            return DatabaseManager.GetManager().GetEntities().planning.FirstOrDefault(p => p.filmfilm_id == movieID && p.datum == date.Date && p.tijd == movieTime);
        }

        public List<planning> GetPlannings(DateTime date)
        {
            TimeSpan timeNow = DateTime.Now.TimeOfDay;
            return DatabaseManager.GetManager().GetEntities().planning.Where(a => a.datum == date.Date && a.tijd >= timeNow ).OrderBy( a => a.tijd ).ToList();
        }
        #endregion
    }
}
